﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinaer.IBll;
using Chinaer.Model.Common;
using Chinaer.Core.Helper;

namespace Chinaer.Bll
{
    public class DianPuYingYeStatus : Repository, IDianPuYingYeStatus
    {
        IDao.IDianPuYingYeStatusDAO dianPuYingYeStatusDAO = new Dao.DianPuYingYeStatusDAO();
        public JsonResult Add(DTO.DianPuYingYeStatusDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_DianPuYingYeStatus model_DianPuYingYeStatus = new Model.Entities.Model_DianPuYingYeStatus();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_DianPuYingYeStatus);
            if (string.IsNullOrEmpty(model_DianPuYingYeStatus.ID) || model_DianPuYingYeStatus.ID.Trim() == "")
            {
                model_DianPuYingYeStatus.ID = Chinaer.Core.Helper.GenerateIDHelper.GenerateID();
            }
            jsonResult.Success = dianPuYingYeStatusDAO.Add(model_DianPuYingYeStatus);
            return jsonResult;
        }

        public JsonResult Delete(DTO.DianPuYingYeStatusDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_DianPuYingYeStatus model_DianPuYingYeStatus = new Model.Entities.Model_DianPuYingYeStatus();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_DianPuYingYeStatus);
            jsonResult.Success = dianPuYingYeStatusDAO.Delete(model_DianPuYingYeStatus);
            return jsonResult;
        }

        public JsonResult Delete(string id)
        {
            JsonResult jsonResult = new JsonResult();
            jsonResult.Success = dianPuYingYeStatusDAO.Delete(id);
            return jsonResult;
        }

        public JsonResult Update(DTO.DianPuYingYeStatusDTO t)
        {
            if (t.CheckIsNull().Success == false)
            {
                return t.CheckIsNull();
            }
            JsonResult jsonResult = new JsonResult();
            Model.Entities.Model_DianPuYingYeStatus model_DianPuYingYeStatus = new Model.Entities.Model_DianPuYingYeStatus();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(t, model_DianPuYingYeStatus);
            jsonResult.Success = dianPuYingYeStatusDAO.Update(model_DianPuYingYeStatus);
            return jsonResult;
        }

        public DTO.DianPuYingYeStatusDTO GetByID(string id)
        {
            Model.Entities.Model_DianPuYingYeStatus model_DianPuYingYeStatus = new Model.Entities.Model_DianPuYingYeStatus();
            model_DianPuYingYeStatus = dianPuYingYeStatusDAO.GetByID(id);
            DTO.DianPuYingYeStatusDTO dianPuYingYeStatusDTO = new DTO.DianPuYingYeStatusDTO();
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(model_DianPuYingYeStatus, dianPuYingYeStatusDTO);
            return dianPuYingYeStatusDTO;
        }

        public DTO.DianPuYingYeStatusDTO GetDianPuYingYeStatusByDianPuID(string dianPuID)
        {
            Model.Entities.Model_DianPuYingYeStatus model_DianPuYingYeStatus = new Model.Entities.Model_DianPuYingYeStatus();
            DTO.DianPuYingYeStatusDTO dianPuYingYeStatusDTO = new DTO.DianPuYingYeStatusDTO();
            model_DianPuYingYeStatus = dianPuYingYeStatusDAO.GetDianPuYingYeStatusByDianPuID(dianPuID);
            Chinaer.Core.Helper.DTOtoEntityObjectHelper.Instance.DTOtoEntityObject(model_DianPuYingYeStatus, dianPuYingYeStatusDTO);
            return dianPuYingYeStatusDTO;
        }
    }
}
